/*    */ package com.wzh.action.control.ad;
/*    */ 
/*    */ import com.opensymphony.xwork2.ActionContext;
/*    */ import com.opensymphony.xwork2.ActionSupport;
/*    */ import com.wzh.bean.PageView;
/*    */ import com.wzh.bean.QueryResult;
/*    */ import com.wzh.bean.ad.Adjs;
/*    */ import com.wzh.service.ad.AdjsService;
/*    */ import javax.annotation.Resource;
/*    */ import org.springframework.stereotype.Controller;
/*    */ 
/*    */ @Controller
/*    */ public class AdjsAction extends ActionSupport
/*    */ {
/*    */   private static final long serialVersionUID = 1L;
/*    */ 
/*    */   @Resource
/*    */   private AdjsService adService;
/* 20 */   private int page = 1;
/*    */   private Adjs ad;
/*    */ 
/*    */   public int getPage()
/*    */   {
/* 27 */     return this.page;
/*    */   }
/*    */ 
/*    */   public void setPage(int page) {
/* 31 */     this.page = page;
/*    */   }
/*    */ 
/*    */   public Adjs getAd() {
/* 35 */     return this.ad;
/*    */   }
/*    */ 
/*    */   public void setAd(Adjs ad) {
/* 39 */     this.ad = ad;
/*    */   }
/*    */ 
/*    */   public String index() {
/* 43 */     PageView pageView = new PageView(10, this.page);
/* 44 */     QueryResult qr = this.adService.getScrollData();
/* 45 */     pageView.setRecords(qr.getResultlist());
/* 46 */     pageView.setTotalrecords((int)qr.getTotalrecord());
/* 47 */     ActionContext.getContext().put("pageView", pageView);
/* 48 */     return "index";
/*    */   }
/*    */ 
/*    */   public String edit()
/*    */   {
/* 55 */     this.ad = ((Adjs)this.adService.find(this.ad.getId()));
/* 56 */     return "edit";
/*    */   }
/*    */ 
/*    */   public String add()
/*    */   {
/* 62 */     return "add";
/*    */   }
/*    */ 
/*    */   public String insert()
/*    */   {
/* 67 */     if (this.adService.isExist(this.ad.getFilename()))
/*    */     {
/* 69 */       ActionContext.getContext().put("message", "文件名已经存在，请重新输入");
/* 70 */       ActionContext.getContext().put("urladdress", "/control/ad/add");
/*    */     } else {
/* 72 */       this.adService.save(this.ad);
/* 73 */       ActionContext.getContext().put("message", "广告添加成功");
/* 74 */       ActionContext.getContext().put("urladdress", "/control/ad/index");
/*    */     }
/* 76 */     return "message";
/*    */   }
/*    */ 
/*    */   public String update() {
/* 80 */     this.adService.update(this.ad);
/* 81 */     ActionContext.getContext().put("message", "广告修改成功");
/* 82 */     ActionContext.getContext().put("urladdress", "/control/ad/index");
/* 83 */     return "message";
/*    */   }
/*    */ 
/*    */   public String delete()
/*    */   {
/* 90 */     this.adService.delete(this.ad.getId(), this.ad.getFilename());
/* 91 */     ActionContext.getContext().put("message", "广告删除成功");
/* 92 */     ActionContext.getContext().put("urladdress", "/control/ad/index");
/* 93 */     return "message";
/*    */   }
/*    */ }

/* Location:           C:\work\apache-tomcat-7.0.55\webapps\ROOT\WEB-INF\classes\
 * Qualified Name:     com.wzh.action.control.ad.AdjsAction
 * JD-Core Version:    0.6.1
 */